package com.sunwayworld.basemodule.business.result.outorder.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.sunwayworld.framework.at.annotation.AuditTrailType;
import com.sunwayworld.framework.at.annotation.AuditTrailEntry;
import com.sunwayworld.framework.spring.annotation.GikamBean;

import com.sunwayworld.basemodule.business.result.outorder.dao.LimsRunOutsendDao;
import com.sunwayworld.basemodule.business.result.outorder.bean.LimsRunOutsendBean;
import com.sunwayworld.basemodule.business.result.outorder.service.LimsRunOutsendService;
import com.sunwayworld.framework.context.ApplicationContextHelper;
import com.sunwayworld.framework.restful.data.RestJsonWrapperBean;

@Repository
@GikamBean
public class LimsRunOutsendServiceImpl implements LimsRunOutsendService {

    @Autowired
    private LimsRunOutsendDao limsRunOutsendDao;

    @Override
    @SuppressWarnings("unchecked")
    public LimsRunOutsendDao getDao() {
        return limsRunOutsendDao;
    }

    @Override
    @Transactional
    @AuditTrailEntry(AuditTrailType.INSERT)
    public Long insert(RestJsonWrapperBean jsonWrapper) {
        LimsRunOutsendBean limsRunOutsend = jsonWrapper.parseUnique(LimsRunOutsendBean.class);
        limsRunOutsend.setId(ApplicationContextHelper.getNextIdentity());
        getDao().insert(limsRunOutsend);
        return limsRunOutsend.getId();
    }

}
